package com.ruoyi.cms.domain.dto;

import java.util.List;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.ruoyi.cms.domain.CmsModelField;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.experimental.Accessors;
import javax.validation.constraints.NotEmpty;
import javax.validation.constraints.NotNull;
import org.hibernate.validator.constraints.Length;
import javax.validation.constraints.Pattern;

import com.ruoyi.cms.domain.CmsModel;
/**
 * 数据模型对象 cms_model
 *
 * @author ruoyi
 * @date 2021-07-29
 */
@ApiModel("数据模型对象")
@Data
@Accessors(chain = true)
public class CmsModelDTO  {

    /** 模型ID - bigint(20) */
    @ApiModelProperty(value = "模型ID（主键.新增时为空,修改时必填!）")
    private Long modelId;

    /** 站点ID - bigint(20) */
    @ApiModelProperty(value = "站点ID", required = false)
    private Long siteId;

    /** 模型名称 - varchar(50) */
    @ApiModelProperty(value = "模型名称", required = false)
    @Length(max = 50, message = "模型名称限制最多50个字符!")
    private String modelName;

    /** 表格名称 - varchar(50) */
    @ApiModelProperty(value = "表格名称", required = false)
    @Length(max = 50, message = "表格名称限制最多50个字符!")
    private String tableName;

    /** 模型类别（1内容模型 2表单模型） - char(1) */
    @ApiModelProperty(value = "模型类别（1内容模型 2表单模型）", required = false)
    @Pattern(regexp = "^$|^(1|2)$", message = "模型类别数据格式错误!")
    private String modelType;

    /** 状态（0正常 1停用） - char(1) */
    @ApiModelProperty(value = "状态（0正常 1停用）", required = false)
    @Pattern(regexp = "^$|^(0|1)$", message = "状态数据格式错误!")
    private String status;

    /** 删除标志（0代表存在 2代表删除） - char(1) */
    @ApiModelProperty(value = "删除标志（0代表存在 2代表删除）", required = false)
    @Pattern(regexp = "^$|^(0|2)$", message = "删除标志数据格式错误!")
    private String delFlag;

    /** 创建人 - varchar(64) */
    @ApiModelProperty(value = "创建人", required = false)
    @Length(max = 64, message = "创建人限制最多64个字符!")
    private String createBy;

    /** 创建时间 - datetime */
    @ApiModelProperty(value = "创建时间", required = false)
    private Date createTime;

    /** 修改人 - varchar(64) */
    @ApiModelProperty(value = "修改人", required = false)
    @Length(max = 64, message = "修改人限制最多64个字符!")
    private String updateBy;

    /** 修改时间 - datetime */
    @ApiModelProperty(value = "修改时间", required = false)
    private Date updateTime;

    /** 数据模型字段信息 */
    @ApiModelProperty(value = " 数据模型字段信息")
    private List<CmsModelField> cmsModelFieldList;

    @JsonIgnore
    @ApiModelProperty(value = "额外参数", required = false, hidden = true)
    Map<String, Object> params = new HashMap<>();

    /** 构造方法 */
    public CmsModelDTO() {}

    /** 构造方法 com.ruoyi.cms.domain.CmsModel  */
    public CmsModelDTO(CmsModel data) {
        this.setModelId(data.getModelId());
        this.setSiteId(data.getSiteId());
        this.setModelName(data.getModelName());
        this.setTableName(data.getTableName());
        this.setModelType(data.getModelType());
        this.setStatus(data.getStatus());
        this.setDelFlag(data.getDelFlag());
        this.setCreateBy(data.getCreateBy());
        this.setCreateTime(data.getCreateTime());
        this.setUpdateBy(data.getUpdateBy());
        this.setUpdateTime(data.getUpdateTime());
        this.setCmsModelFieldList(data.getCmsModelFieldList());
    }

    /**
    * 转换为 com.ruoyi.cms.domain.CmsModel
    */
    public CmsModel as() {
        CmsModel data = new CmsModel();
        data.setModelId(this.getModelId());
        data.setSiteId(this.getSiteId());
        data.setModelName(this.getModelName());
        data.setTableName(this.getTableName());
        data.setModelType(this.getModelType());
        data.setStatus(this.getStatus());
        data.setDelFlag(this.getDelFlag());
        data.setCreateBy(this.getCreateBy());
        data.setCreateTime(this.getCreateTime());
        data.setUpdateBy(this.getUpdateBy());
        data.setUpdateTime(this.getUpdateTime());
        data.setCmsModelFieldList(this.getCmsModelFieldList());
        return data;
    }


}
